#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void main(void)
{
	srand(time(NULL));  // Seed once
	int i, guess, answer;
	answer = rand() % 10 + 1;
	printf("Try to guess the right number \nbetween 1 and 10!\n You have 3 chances.\n");
	printf("\nFirst guess,please type a number.\n");
	scanf("%d",&guess);
	if (guess<answer)
	{
		printf("\nTry a bigger number\n");
	}
	if (guess>answer)
	{
		printf("\nTry a smaller number\n");
	}
	if (guess==answer)
	{
		printf("\nCongratulations, winner\n");
	}
	printf("\nSecond guess,please type a number.\n");
	scanf("%d",&guess);
	if (guess<answer)
	{
		printf("\nTry a bigger number\n");
	}
	if (guess>answer)
	{
		printf("\nTry a smaller number\n");
	}
	if (guess==answer)
	{
		printf("\nCongratulations, winner\n");
	}
	printf("\nThird guess, please type a number.\n");
	scanf ("%d", &guess);
	if (guess==answer)
	{
		printf("\nCongratulations, winner\n");
	}
	if (guess!=answer)
		printf("\nYou lost the game\n");
}
